﻿using System;

namespace UniRx.Operators
{
	// Token: 0x020003F8 RID: 1016
	internal class SubscribeOnMainThreadObservable<T> : OperatorObservableBase<T>
	{
		// Token: 0x060014C2 RID: 5314 RVA: 0x0005DBC0 File Offset: 0x0005BFC0
		public SubscribeOnMainThreadObservable(IObservable<T> source, IObservable<long> subscribeTrigger) : base(source.IsRequiredSubscribeOnCurrentThread<T>())
		{
			this.source = source;
			this.subscribeTrigger = subscribeTrigger;
		}

		// Token: 0x060014C3 RID: 5315 RVA: 0x0005DBDC File Offset: 0x0005BFDC
		protected override IDisposable SubscribeCore(IObserver<T> observer, IDisposable cancel)
		{
			SingleAssignmentDisposable singleAssignmentDisposable = new SingleAssignmentDisposable();
			SerialDisposable serialDisposable = new SerialDisposable();
			serialDisposable.Disposable = singleAssignmentDisposable;
			singleAssignmentDisposable.Disposable = this.subscribeTrigger.SubscribeWithState3(observer, serialDisposable, this.source, delegate(long _, IObserver<T> o, SerialDisposable disp, IObservable<T> s)
			{
				disp.Disposable = s.Subscribe(o);
			});
			return serialDisposable;
		}

		// Token: 0x04000C0E RID: 3086
		private readonly IObservable<T> source;

		// Token: 0x04000C0F RID: 3087
		private readonly IObservable<long> subscribeTrigger;
	}
}
